<template>
  <div id="app">
    <nav v-if="$route.meta.showNav">
      <router-link to="/">推荐</router-link> |
      <router-link to="/hot">热歌</router-link> |
      <router-link to="/search">搜索</router-link>
    </nav>
    <router-view
      @update:currentSong="currentSong = $event"
      :currentSong="currentSong"
      :playing="playing"
    />
    <audio
      style="height: 30px"
      :src="
        currentSong &&
        `https://music.163.com/song/media/outer/url?id=${currentSong.id}.mp3`
      "
      controls
      autoplay
      @play="playing = true"
      @pause="playing = false"
    ></audio>
  </div>
</template>
<script>
export default {
  data: function () {
    return {
      currentSong: null,
      playing: false,
    };
  },
};
</script>

<style lang="less">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
}

nav {
  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
